package util;

import java.awt.Dimension;
import java.awt.Toolkit;

import javax.swing.JFrame;

public abstract class BaseFrame extends JFrame{//模板设计模式
	//设计一个规则  任何窗口想要画出来  执行流程固定
	public BaseFrame(String title) {
		super (title);
	}
	public BaseFrame() {
		
	}
	protected void init() {//按流程执行方法
		this.setFontAndSoOn();
		this.addElement();
		this.addListener();
		this.setFrameSelf();
	}
	//设置 字体 颜色 背景 布局 等
	protected abstract void setFontAndSoOn(); 
	//将属性添加到窗体里
	protected abstract void addElement();
	//绑定事件监听
	protected abstract void addListener();
	//设置窗体自身
	protected abstract void setFrameSelf();
	//窗体居中方法
	protected void setCenterFrame(int width,int height) {
		Toolkit kit = Toolkit.getDefaultToolkit();
		Dimension screenSize = kit.getScreenSize();
		int screenWidth = screenSize.width/2;
		int screenHeight = screenSize.height/2;
		this.setBounds(screenWidth-width/2, screenHeight-height/2, width, height);
	}
}
